* Sociology 229: Advanced Regression 2010 * Evan Schofer * Thanks to Xinxiang Chen, who created the original datafile and example * Open the datafile use "C:\Users\schofer\Documents\Classes\Soc 229 Adv Reg\Assignment 5 Multilevel.dta", clear * OLS regress math female white ses * OLS with robust standard errors adjusted for clustering by school regress math female white ses, vce(cluster schoolid) * Between regression (aggregate analysis at school level) xtreg math female white ses, i(schoolid) be * Within regression (fixed effects) xtreg math female white ses, i(schoolid) fe * Random intercept model (Note: could also estimate via option "mle") xtreg math female white ses, i(schoolid) re xtreg math female white ses, i(schoolid) mle * Hausman test xtreg math female white ses, i(schoolid) fe estimates store fixed xtreg math female white ses, i(schoolid) re estimates store random hausman fixed random * Include school mean SES to model group and individual-level effect xtreg math female white ses meanses schoolsize, i(schoolid) fe xtreg math female white ses meanses schoolsize, i(schoolid) re * Look at time spent on homework xtreg math female white ses meanses homework schoolsize, i(schoolid) re * Allow random slope for meanSES xtmixed math female white ses meanses homework schoolsize|| schoolid: meanses, mle cov(unstr)